package com.steven.door.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.steven.door.services.WebSocketService;
import com.steven.door.utils.NetCheckUtil;

public class NetChangeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        assert action != null;
        if (action.equals("android.net.conn.CONNECTIVITY_CHANGE")) {
            if (NetCheckUtil.checkNet(context))
                context.startService(new Intent(context, WebSocketService.class));//启动服务 链接socket
        }
    }
}
